import { MDViewActionType, IMDViewAbility, IParam } from '@/core/interface';
import { IMDViewController } from '@/core/interface/view/controller';
import { IMDViewStore } from '@/core/interface/view/store';
import { IMDCtrlAbility } from '@/core/interface/widgets/ability';
import { MDViewControllerBase } from './md-view-controller-base';

/**
 * 多数据视图控制器
 *
 * @export
 * @class MDViewController
 * @extends {DEViewController<T, S, A>}
 * @implements {IMDViewController}
 */
export class MDViewController
	extends MDViewControllerBase<MDViewActionType, IMDViewStore, IMDViewAbility>
	implements IMDViewController<IMDViewStore, IMDViewAbility>
{
	/**
	 * 获取多数据部件能力
	 *
	 * @protected
	 * @return {*}  {(IListAbility | undefined)}
	 * @memberof GridViewController
	 */
	protected getMDCtrlAbility(): IMDCtrlAbility | undefined {
		const list = this.model.ctrls.find(
			(ctrl: IParam) => ctrl.controlType === 'MOBMDCTRL'
		);
		if (list) {
			return this.getSubAbility<IMDCtrlAbility>(list.name);
		}
		return undefined;
	}
}
